$(document).ready(function() {
    var toto;
    $('.buttonAffecterArbitre').on('click', function(e) {

        var form = $(this).parent('form');
        var url = form.attr('action');
	var this_ = $(this);
        $.ajax({
            type: 'POST',
            url: url,
            data: form.serialize(),
            success: function(response)
            {
                console.log(response);
                toto = response;
                if (response.resultCode === "OK") {
		    
		    if( form.parent('td').prev('td').html() !== "" && form.parent('td').prev('td').prev('td').html() !== "")
		    {
			form.parent('td').next('td').find('button').addClass('green').prop('disabled', false);
		    }
		    form.parent('td').html(response.values['nomPrenom']);
                }
                else {
                    
                }
            }
        });
        e.preventDefault();
        return false;
    });

});
